package testView;

import model.Puzzle;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * @author Beth Katz and David Hutchens
 *
 * Tests the puzzle class.
 */
public class PuzzleTest {
	private char[ ][ ] m = { 
			{'p', 'o', 'o', 'w', 's'}, // row 1 in puzzle
			{'s', 'a', 'o', 'a', 'h'}, // row 2
			{'g', 'n', 'u', 'p', 'e'}, // row 3
			{'s', 'u', 'p', 'o', 'd'}  // row 4
	};

	/**
	 * test finding words going in northeast direction
	 */
	@Test
	public void testPuzzleNE() {
		Puzzle p = new Puzzle(m);
		String theAnswer;
		
		theAnswer = p.locationInPuzzle("now");		
		assertTrue(theAnswer.equalsIgnoreCase("now at 3,2 going NE\n"));
	}

	/**
	 * test finding words going in west direction
	 */
	@Test
	public void testPuzzleW() {
		Puzzle p = new Puzzle(m);
		String theAnswer;
		
		theAnswer = p.locationInPuzzle("swoop");		
		assertTrue(theAnswer.equalsIgnoreCase("swoop at 1,5 going W\n"));
	}

	/**
	 * test finding words not in the puzzle
	 */	
	@Test
	public void testPuzzleNotFound() {
		Puzzle p = new Puzzle(m);
		String theAnswer;
		
		theAnswer = p.locationInPuzzle("rain");
 		assertTrue(theAnswer.length( ) == 0);
	}

}
